<template>
<h1>猜数字练习</h1>
  <input type="text" placeholder="请输入您猜的数字" v-model="num">
  <button @click="guess">猜一下</button>
  <h4>小提示:{{result}}</h4>
</template>

<script setup>
import {ref} from "vue";
const num =ref('');
const result =ref('');
let x =parseInt(Math.random()*100)+1;
console.log(x);
const guess=()=>{
   if (num.value>x){
     result.value='猜大了';
   }else if (num.value<x){
     result.value='猜小的';
   }else {
     result.value='猜对了'
   }
}
</script>


<style scoped>

</style>